package com.mj.page;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 分页查询返回结果
 */
public class PageInfoBean<T> implements Serializable {

	private static final long serialVersionUID = -1542321928148172331L;

	/**
	 * 总记录数
	 */
	private int totalRecordNum;

	/**
	 * 当前页数
	 */
	private int pageNo;

	/**
	 * 一页记录数
	 */
	private int pageSize;

	/**
	 * 总页数
	 */
	private int pages;

	/**
	 * 查询条件
	 */
	private Map<String, Object> condition = new HashMap<String, Object>();

	/**
	 * 结果集
	 */
	private List<T> list;

	public PageInfoBean() {
		super();
	}

	public PageInfoBean(int total, int pageNo, int pageSize, Map<String, Object> condition, List<T> list) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.condition = condition;
		this.list = list;
		this.totalRecordNum = total; // 获取总记录数
		if (pageSize != 0) {
			this.pages = (int) Math.ceil((double) totalRecordNum / (double) pageSize);
		} else {
			this.pages = 0;
		}
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Map<String, Object> getCondition() {
		return condition;
	}

	public void setCondition(Map<String, Object> condition) {
		this.condition = condition;
	}

	public int getPages() {
		return pages;
	}

	public void setPages(int pages) {
		this.pages = pages;
	}

	public int getTotalRecordNum() {
		return totalRecordNum;
	}

	public void setTotalRecordNum(int totalRecordNum) {
		this.totalRecordNum = totalRecordNum;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

}
